#include "pix5core.h"

Mutex::Mutex()
{
	pthread_mutexattr_init(&_attr);
	pthread_mutexattr_settype(&_attr,PTHREAD_MUTEX_RECURSIVE);
	pthread_mutex_init(&_mtx,&_attr);
}

Mutex::~Mutex()
{
	pthread_mutex_destroy(&_mtx);
	pthread_mutexattr_destroy(&_attr);
}


void Mutex::lock()
{
	pthread_mutex_lock(&_mtx);
}

bool Mutex::tryLock()
{
	return pthread_mutex_trylock(&_mtx)==0;
}

void Mutex::unlock()
{
	pthread_mutex_unlock(&_mtx);
}


